#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 3010;
int a[N];
ll sum, minx = 1000000;
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) 
		cin >> a[i];
	for(int i = 1; i <= n - m + 1; i++)
	{
		sum = 0;
		for (int j = i; j <= i + m - 1; j++)
		{
			sum += a[j];
		}
		minx = min(minx, sum);
	}
	cout << minx << endl;
	return 0;
}